Skip to content

Focus Zed if running, else the OpenCode TUI - #5

Merged
gabparrot merged 2 commits into
mainfrom
focus-tui-on-click
Aug 22, 2026
Merged

Focus Zed if running, else the OpenCode TUI#5
gabparrot merged 2 commits into
mainfrom
focus-tui-on-click

Conversation

@gabparrot

Copy link
Copy Markdown
Owner

Summary

Clicking a notification now focuses running Zed, else a running OpenCode TUI. It no longer launches Zed when only the TUI is up.

Policy

  1. clickCommand still wins and short-circuits.
  2. Zed is running only if a zed-*.sock exists and a connect-only probe succeeds (stale sockets do not count).
  3. If Zed is running: focus it (zed://, with XDG_ACTIVATION_TOKEN when the compositor sent one) and return even if raise fails.
  4. Else: raise a running OpenCode TUI via ps classification, then hyprctl / sway / niri / DBusActivatable terminal (NameHasOwner first) / wmctrl.
  5. opencode acp, opencode2 serve, and similar are not treated as TUI.
  6. No xdotool. Fail open — notify still sends if focus is unavailable.

Tests

bun run typecheck and bun test (113 pass).

Note

GNOME + gnome-terminal (and some other terminals) may not raise; TUI focus is compositor best-effort.

Click no longer launches Zed when only the TUI is up. A live zed-*.sock
means focus Zed; otherwise raise a running opencode TUI via compositor
or DBusActivatable terminal activate.
@gabparrot
gabparrot merged commit 6d56151 into main Aug 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant